from sklearn.linear_model import LinearRegression
import pandas as pd

# 1.准备数据
df_data = pd.read_csv("height_weight_10k.csv", encoding='utf-8')
x_data = df_data.iloc[:, 0].values.reshape(-1, 1)
y_data = df_data.iloc[:, 1].values

# 2.特征方程
# 标准化

# 3.模型训练
model = LinearRegression()
model.fit(x_data, y_data)

print(f"斜率是：{model.coef_}")
print(f"截距是：{model.intercept_}")

# 4.数据预测

result = model.predict([[167.5]])
print(f"预测体重为：{result}")
